# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=nimble
pkgver=0.13.1
pkgrel=3
pkgdesc="Package manager for the Nim programming language"
url="https://github.com/nim-lang/nimble"
arch="all !s390x"
license="BSD-3-Clause"
depends="nim libssl3"
subpackages="$pkgname-bash-completion $pkgname-zsh-completion"
source="https://github.com/nim-lang/$pkgname/archive/v$pkgver/$pkgname-$pkgver.tar.gz
	fix-test.patch
	"

prepare() {
	default_prepare

	# XXX: This is a workaround for missing option in unittest to skip/exclude
	# particular suite(s).
	# - Remove test suite "issues" - some tests require additional dependencies
	#   and/or are too complex and takes eternity to complete.
	# - Additionaly, we have to remove test "compile without warnings" because
	#   it runs tester.nim with linter; after we removed the "issues" test
	#   suite, there are some unused functions, so this test doesn't pass.
	sed -i \
		-e '/^suite "issues":/,/^suite /d' \
		-e '/test "compilation without warnings":/,/test "/d' \
		tests/tester.nim
}

build() {
	nim compile -d:release src/nimble
}

check() {
	cd tests
	nim c -r tester
}

package() {
	install -D -m 755 src/nimble "$pkgdir"/usr/bin/nimble

	install -D -m 644 nimble.zsh-completion \
		"$pkgdir"/usr/share/zsh/site-functions/_nimble

	install -D -m 644 nimble.bash-completion \
		"$pkgdir"/usr/share/bash-completion/completions/nimble
}

sha512sums="
d13fc755e2018911faa1039ca6c73a3ecaa7aa57fb57faee9babb750155ac5e73be4f60110ee64cdd56874245f7c046d6c825356fd84a8fcbba9683db2406520  nimble-0.13.1.tar.gz
9c0541fdca2a2a5be3a79ca96a29de1de23ef1679797f1179549a67ad3cd4b7243b8dc2c5cd8b06b185eacfe81fa781fd561e118c1ba2f45599d2f67cce2dfd8  fix-test.patch
"
